<template>
  <base-page-view class-name="page-container">
    <view class="nick">
      <input v-model="nike" class="uni-input" focus placeholder="请输入12个以内的字符" />
    </view>
    <view class="update_btn" @click="updateNike">
      修改
    </view>
  </base-page-view>
</template>

<script>
import './index.scss'
export default {
  components: {
  },
  data() {
    return {
      nike: ''
    }
  },
  created() {
  },
  onLoad(option) {
    this.nike = JSON.parse(decodeURIComponent(option.nike))
  },
  onShow() {

  },
  methods: {
    updateNike() {
      const nickname = this.nike.trim()
      if (!nickname) {
        uni.showToast({
          title: '请输入昵称',
          icon: 'none'
        })
        return
      }
      this.$api.mineApi.setMyInfo({
        nickname: nickname,
        hideLoading: true
      }).then((res) => {
        // console.log(res)
        uni.navigateBack()
      })
    }
  }
}
</script>
